<?php
session_start();
require("config.php");
ini_set('display_errors',0);
$pagina = new Template($config['dir_templates'], "keep");
$pagina->set_file(array(
				"sistema" => "report.htm",
				"report1" => "report1.htm"));

$pagina->set_block("report1","ITEM","bITEM");

if (($_REQUEST['report'] == "1") && ($_SESSION['level'] <= 6) && ($_SESSION['period'] > 0)){
	$db = new MySQL();
	$period=$_SESSION['period'];
	$emp=$_SESSION['iniciales'];
	
	if ($_REQUEST['diaReporte']!=""){
		$pday=$_REQUEST['diaReporte'];
		$period=$_SESSION['period'];
		$pyear=$_SESSION['pyear'];
		
		$consulta = $db->consulta("SELECT DAYOFMONTH(`ini`) dia, MONTH (`ini`) mes, YEAR(`ini`) year FROM `range_period` WHERE `period` = $period and YEAR(`ini`)=$pyear and YEAR(`fin`)=$pyear");
		$resultados = $db->fetch_array($consulta); 
		$dia=$resultados['dia'];
		$mes=$resultados['mes'];
		$year=$resultados['year'];
		$fecha=mktime(0, 0, 0, $mes, $dia, $year);
		$fecha=$fecha+(($pday-1)*24*60*60);
		$date=date("l j-m-Y", $_SESSION['date']);
		//$pdate=date("j-m-Y", $fecha);
		$pdate=date("m-d-y", $fecha);
		$diaYearAnterior=date("j", $fecha);
		$diaWeek=date("l", $fecha);
		
	}
	else{ 

		$pday=$_SESSION['pday'];
		$pyear=$_SESSION['pyear'];
		$period=$_SESSION['period'];
		$date=date("l j-m-Y", $_SESSION['date']);
		$pdate=date("m-d-y", $_SESSION['date']);
		$diaYearAnterior=date("j", $_SESSION['date']);
		$diaWeek=date("l", $_SESSION['date']);
	}
	$consulta = $db->consulta("SELECT * FROM `range_period` where `period` = $period and ypyear = $pyear");
	while ($inicio=$db->fetch_array($consulta)){
		$fechaIni=split("-",$inicio['ini']);
		if ($fechaIni[0]==$pyear){
			$anterior=$fechaIni[0]-1;
		}
	}
	$fechaInicio=$fechaIni[2]."-".$fechaIni[1]."-".$fechaIni[0];
	$yearAnterior=$fechaIni[2]."-".$fechaIni[1]."-".$anterior;
	$periodoAnterior=$diaYearAnterior."-".$fechaIni[1]."-".$anterior;
	$hotel=$_SESSION['hotel'];
	
	$pagina->set_var("PERIOD","$period");
	$pagina->set_var("PYEAR","$pyear");
	$pagina->set_var("PDAY","$pday");
	$pagina->set_var("DATE","$date");
	$pagina->set_var("PDATE","$pdate");
	$pagina->set_var("DIA","$diaWeek");
	$color="#F5F5F5";

	$sumaActual=0;$sumaBudget=0;$sumaLy=0;$sumaActualP=0;$sumaBudgetP=0;$sumaLyP=0;
	$sumaActualT=0;$sumaBudgetT=0;$sumaLyT=0;$sumaActualPT=0;$sumaBudgetPT=0;$sumaLyPT=0;
	
	
//******************************************************LINEA 1 h1****************************************************************	

	$consulta = $db->consulta("SELECT * FROM `cb_budget` where `hotel` like '$hotel' or `hotel` like 'TD' order by `orden` asc");
	$datos=$db->fetch_array($consulta);
	$item=$datos['name'];
	
	$pagina->set_var("ITEM_NAME","Rooms - Transient");
	
	$trs_sales=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$actual=0;
	$valorActual=$db->fetch_array($trs_sales);
	$actual=$actual+$valorActual['suma'];
	$sumaActual=$sumaActual+$actual;
	$actual=number_format($actual,0,".",",");
	$pagina->set_var("ACTUAL","$actual");
	
	$item_=str_replace(" ","_",$item);
	$budgetQ=$db->consulta("SELECT * FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' AND `pday` = '$pday' AND `pyear` = '$pyear' and (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");
	$valorBudget=$db->fetch_array($budgetQ);
	$budget=round($valorBudget['cantidad']);
	
	$sumaBudget=$sumaBudget+$budget;
	
	$budget=number_format($budget,0,".",",");
	
	$pagina->set_var("T_BUDGET","$budget");
	
	$pyear2=$pyear-1;
	$lyB=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorLy=$db->fetch_array($lyB);
	$ly=round($valorLy['suma']);
	
	$sumaLy=$sumaLy+$ly;
	
	$ly=number_format($ly,0,".",",");
	
	$pagina->set_var("T_LY","$ly");
	
	$pyear2=$pyear-1;
	$pActual=$db->consulta("SELECT round(sum(`room_sales`)) sum FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorPactual=$db->fetch_array($pActual);
	$p_Actual=round($valorPactual['sum']);
	
	$sumaActualP=$sumaActualP+$p_Actual;
	
	$p_Actual=number_format($p_Actual,0,".",",");
	
	$pagina->set_var("P_ACTUAL","$p_Actual");
	
	$budgetP=$db->consulta("SELECT round(sum(`cantidad`)) sumP FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
	$valorBudgetP=$db->fetch_array($budgetP);
	$budgetPer=round($valorBudgetP['sumP']);
	
	$sumaBudgetP=$sumaBudgetP+$budgetPer;
	
	$budgetPer=number_format($budgetPer,0,".",",");
	
	$pagina->set_var("P_BUDGET","$budgetPer");
	
	$pdate2=$yearAnterior;
	$lyP=$db->consulta("SELECT round(sum(`room_sales`)) sum FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorLyP=$db->fetch_array($lyP);
	$lyPer=round($valorLyP['sum']);
	
	$sumaLyP=$sumaLyP+$lyPer;
	$lyPer=number_format($lyPer,0,".",",");
	$pagina->set_var("P_LY","$lyPer");
	
	if ($color=="#F5F5F5"){$color = "#FCFCFC";}
	else{$color = "#F5F5F5";}
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);		
	
//******************************************************LINEA 2 h1****************************************************************	
	
	$datos=$db->fetch_array($consulta);
	$item=$datos['name'];
	
	$pagina->set_var("ITEM_NAME","Rooms - Group");
	
	$cgrDolars=$db->consulta("SELECT round(sum(`dollars`)) suma FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))  and `hnivel` = 1");
	$actual=0;
	$valorActual=$db->fetch_array($cgrDolars);
	$actual=$actual+$valorActual['suma'];
	
	$sumaActual=$sumaActual+$actual;
	$actual=number_format($actual,0,".",",");
	$pagina->set_var("ACTUAL","$actual");
	
	$item_=str_replace(" ","_",$item);
	$budgetQ=$db->consulta("SELECT * FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' AND `pday` = '$pday' AND `pyear` = '$pyear' and (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");
	$valorBudget=$db->fetch_array($budgetQ);
	$budget=round($valorBudget['cantidad']);
	
	$sumaBudget=$sumaBudget+$budget;
	$budget=number_format($budget,0,".",",");
	$pagina->set_var("T_BUDGET","$budget");

	$lyB=$db->consulta("SELECT round(sum(`dollars`)) suma FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorLy=$db->fetch_array($lyB);
	$ly=round($valorLy['suma']);
	
	$sumaLy=$sumaLy+$ly;
	$ly=number_format($ly,0,".",",");
	$pagina->set_var("T_LY","$ly");
	
	$pdate2=$fechaInicio;
	$pActual=$db->consulta("SELECT round(sum(`dollars`)) sum FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorPactual=$db->fetch_array($pActual);
	$p_Actual=round($valorPactual['sum']);
	
	$sumaActualP=$sumaActualP+$p_Actual;
	$p_Actual=number_format($p_Actual,0,".",",");
	$pagina->set_var("P_ACTUAL","$p_Actual");
	/*echo($pdate);
	echo($pdate2);
	echo($item_);
	echo($item);
	echo($hotel);
	exit;
	$budgetP=$db->consulta("SELECT round(sum(`cantidad`)) sumP FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND (str_to_date(`pdate`, '%W %d-%m-%Y') between str_to_date('$pdate2', '%d-%m-%Y') and str_to_date('$pdate', '%d-%m-%Y')) AND (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");*/
	
	$budgetP=$db->consulta("SELECT round(sum(`cantidad`)) sumP FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
	
	$valorBudgetP=$db->fetch_array($budgetP);
	$budgetPer=round($valorBudgetP['sumP']);
	
	$sumaBudgetP=$sumaBudgetP+$budgetPer;
	$budgetPer=number_format($budgetPer,0,".",",");
	$pagina->set_var("P_BUDGET","$budgetPer");
	
	$pyear2=$pyear-1;
	$lyP=$db->consulta("SELECT round(sum(`dollars`)) sumly FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))  and `hnivel` = 1");
	$valorLyP=$db->fetch_array($lyP);
	$lyPer=round($valorLyP['sumly']);
	
	$sumaLyP=$sumaLyP+$lyPer;
	$lyPer=number_format($lyPer,0,".",",");
	$pagina->set_var("P_LY","$lyPer");
	
	
	if ($color=="#F5F5F5"){$color = "#FCFCFC";}
	else{$color = "#F5F5F5";}
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);

//******************************************************LINEA 3 h1***************************************************************	
	
	$datos=$db->fetch_array($consulta);
	$item=$datos['name'];
	
	$pagina->set_var("ITEM_NAME","Rooms - Contract");
	
	$cgrDolars=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1 ");
	$actual=0;
	$valorActual=$db->fetch_array($cgrDolars);
	$actual=$actual+$valorActual['suma'];
	
	$sumaActual=$sumaActual+$actual;
	$actual=number_format($actual,0,".",",");
	$pagina->set_var("ACTUAL","$actual");
	
	$item_=str_replace(" ","_",$item);
	$budgetQ=$db->consulta("SELECT * FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' AND `pday` = '$pday' AND `pyear` = '$pyear' and (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");
	$valorBudget=$db->fetch_array($budgetQ);
	$budget=round($valorBudget['cantidad']);
	
	$sumaBudget=$sumaBudget+$budget;
	$budget=number_format($budget,0,".",",");
	$pagina->set_var("T_BUDGET","$budget");

	$lyB=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorLy=$db->fetch_array($lyB);
	$ly=round($valorLy['suma']);
	
	$sumaLy=$sumaLy+$ly;
	$ly=number_format($ly,0,".",",");
	$pagina->set_var("T_LY","$ly");
	
	$pdate2=$fechaInicio;
	$pActual=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorPactual=$db->fetch_array($pActual);
	$p_Actual=round($valorPactual['suma']);
	
	$sumaActualP=$sumaActualP+$p_Actual;
	$p_Actual=number_format($p_Actual,0,".",",");
	$pagina->set_var("P_ACTUAL","$p_Actual");
	
	$budgetP=$db->consulta("SELECT round(sum(`cantidad`)) sumP FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
	$valorBudgetP=$db->fetch_array($budgetP);
	$budgetPer=round($valorBudgetP['sumP']);
	
	$sumaBudgetP=$sumaBudgetP+$budgetPer;
	$budgetPer=number_format($budgetPer,0,".",",");
	$pagina->set_var("P_BUDGET","$budgetPer");
	
	$pdate2=$yearAnterior;
	$lyP=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 1");
	$valorLyP=$db->fetch_array($lyP);
	$lyPer=round($valorLyP['suma']);
	
	$sumaLyP=$sumaLyP+$lyPer;
	$lyPer=number_format($lyPer,0,".",",");
	$pagina->set_var("P_LY","$lyPer");
	
	
	if ($color=="#F5F5F5"){$color = "#FCFCFC";}
	else{$color = "#F5F5F5";}
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);



//******************************************************LINEA 1 h2************************************************************

	$dbLevel = new MySQL();
	$resultHotelLevel = $dbLevel->consulta("SELECT `hnivel` FROM `hotel_level` WHERE `name` like '$hotel'");
	$hotelLevelQuery=$dbLevel->fetch_array($resultHotelLevel);
	
	if ($hotelLevelQuery['hnivel'] == 2) {
		$datos=$db->fetch_array($consulta);
		$item=$datos['name'];
		
		$pagina->set_var("ITEM_NAME","BA Rooms - Transient");
		
		$trs_sales=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$actual=0;
		$valorActual=$db->fetch_array($trs_sales);
		$actual=$actual+$valorActual['suma'];
		$sumaActual=$sumaActual+$actual;
		$actual=number_format($actual,0,".",",");
		$pagina->set_var("ACTUAL","$actual");
		
		$item_=str_replace(" ","_",$item);
		$budgetQ=$db->consulta("SELECT * FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' AND `pday` = '$pday' AND `pyear` = '$pyear' and (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");
		$valorBudget=$db->fetch_array($budgetQ);
		$budget=round($valorBudget['cantidad']);
		
		$sumaBudget=$sumaBudget+$budget;
		
		$budget=number_format($budget,0,".",",");
		
		$pagina->set_var("T_BUDGET","$budget");
		
		$pyear2=$pyear-1;
		$lyB=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorLy=$db->fetch_array($lyB);
		$ly=round($valorLy['suma']);
		
		$sumaLy=$sumaLy+$ly;
		
		$ly=number_format($ly,0,".",",");
		
		$pagina->set_var("T_LY","$ly");
		
		$pyear2=$pyear-1;
		$pActual=$db->consulta("SELECT round(sum(`room_sales`)) sum FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorPactual=$db->fetch_array($pActual);
		$p_Actual=round($valorPactual['sum']);
		
		$sumaActualP=$sumaActualP+$p_Actual;
		
		$p_Actual=number_format($p_Actual,0,".",",");
		
		$pagina->set_var("P_ACTUAL","$p_Actual");
		
		$budgetP=$db->consulta("SELECT round(sum(`cantidad`)) sumP FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorBudgetP=$db->fetch_array($budgetP);
		$budgetPer=round($valorBudgetP['sumP']);
		
		$sumaBudgetP=$sumaBudgetP+$budgetPer;
		
		$budgetPer=number_format($budgetPer,0,".",",");
		
		$pagina->set_var("P_BUDGET","$budgetPer");
		
		$pdate2=$yearAnterior;
		$lyP=$db->consulta("SELECT round(sum(`room_sales`)) sum FROM `trans_room_segment` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorLyP=$db->fetch_array($lyP);
		$lyPer=round($valorLyP['sum']);
		
		$sumaLyP=$sumaLyP+$lyPer;
		$lyPer=number_format($lyPer,0,".",",");
		$pagina->set_var("P_LY","$lyPer");
		
		if ($color=="#F5F5F5"){$color = "#FCFCFC";}
		else{$color = "#F5F5F5";}
		if ($hotel == "stgo") $hotel = "bx";
		$hotel=strtoupper ($hotel);
	
		$pagina->set_var("BGCOLOR","$color");
		$pagina->set_var("HOTEL","$hotel");
		$pagina->parse("bITEM","ITEM",true);		
		
	//******************************************************LINEA 2 h2**************************************************************	
		
		$datos=$db->fetch_array($consulta);
		$item=$datos['name'];
		
		$pagina->set_var("ITEM_NAME","BA Rooms - Group");
		
		$cgrDolars=$db->consulta("SELECT round(sum(`dollars`)) suma FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2  ");
		$actual=0;
		$valorActual=$db->fetch_array($cgrDolars);
		$actual=$actual+$valorActual['suma'];
		
		$sumaActual=$sumaActual+$actual;
		$actual=number_format($actual,0,".",",");
		$pagina->set_var("ACTUAL","$actual");
		
		$item_=str_replace(" ","_",$item);
		$budgetQ=$db->consulta("SELECT * FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' AND `pday` = '$pday' AND `pyear` = '$pyear' and (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");
		$valorBudget=$db->fetch_array($budgetQ);
		$budget=round($valorBudget['cantidad']);
		
		$sumaBudget=$sumaBudget+$budget;
		$budget=number_format($budget,0,".",",");
		$pagina->set_var("T_BUDGET","$budget");
	
		$lyB=$db->consulta("SELECT round(sum(`dollars`)) suma FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorLy=$db->fetch_array($lyB);
		$ly=round($valorLy['suma']);
		
		$sumaLy=$sumaLy+$ly;
		$ly=number_format($ly,0,".",",");
		$pagina->set_var("T_LY","$ly");
		
		$pdate2=$fechaInicio;
		$pActual=$db->consulta("SELECT round(sum(`dollars`)) sum FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorPactual=$db->fetch_array($pActual);
		$p_Actual=round($valorPactual['sum']);
		
		$sumaActualP=$sumaActualP+$p_Actual;
		$p_Actual=number_format($p_Actual,0,".",",");
		$pagina->set_var("P_ACTUAL","$p_Actual");
		
		$budgetP=$db->consulta("SELECT round(sum(`cantidad`)) sumP FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND (str_to_date(`pdate`, '%W %d-%m-%Y') between str_to_date('$pdate2', '%d-%m-%Y') and str_to_date('$pdate', '%d-%m-%Y')) AND (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");
		$valorBudgetP=$db->fetch_array($budgetP);
		$budgetPer=round($valorBudgetP['sumP']);
		
		$sumaBudgetP=$sumaBudgetP+$budgetPer;
		$budgetPer=number_format($budgetPer,0,".",",");
		$pagina->set_var("P_BUDGET","$budgetPer");
		
		$pyear2=$pyear-1;
		$lyP=$db->consulta("SELECT round(sum(`dollars`)) sumly FROM `corp_gr_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorLyP=$db->fetch_array($lyP);
		$lyPer=round($valorLyP['sumly']);
		
		$sumaLyP=$sumaLyP+$lyPer;
		$lyPer=number_format($lyPer,0,".",",");
		$pagina->set_var("P_LY","$lyPer");
		
		
		if ($color=="#F5F5F5"){$color = "#FCFCFC";}
		else{$color = "#F5F5F5";}
		if ($hotel == "stgo") $hotel = "bx";
		$hotel=strtoupper ($hotel);
	
		$pagina->set_var("BGCOLOR","$color");
		$pagina->set_var("HOTEL","$hotel");
		$pagina->parse("bITEM","ITEM",true);
	
	//******************************************************LINEA 3 h2***************************************************************	
		
		$datos=$db->fetch_array($consulta);
		$item=$datos['name'];
		
		$pagina->set_var("ITEM_NAME","BA Rooms - Contract");
		
		$cgrDolars=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2  ");
		$actual=0;
		$valorActual=$db->fetch_array($cgrDolars);
		$actual=$actual+$valorActual['suma'];
		
		$sumaActual=$sumaActual+$actual;
		$actual=number_format($actual,0,".",",");
		$pagina->set_var("ACTUAL","$actual");
		
		$item_=str_replace(" ","_",$item);
		$budgetQ=$db->consulta("SELECT * FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' AND `pday` = '$pday' AND `pyear` = '$pyear' and (`hotel` LIKE '$hotel' OR `hotel` LIKE 'TD')");
		$valorBudget=$db->fetch_array($budgetQ);
		$budget=round($valorBudget['cantidad']);
		
		$sumaBudget=$sumaBudget+$budget;
		$budget=number_format($budget,0,".",",");
		$pagina->set_var("T_BUDGET","$budget");
	
		$lyB=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorLy=$db->fetch_array($lyB);
		$ly=round($valorLy['suma']);
		
		$sumaLy=$sumaLy+$ly;
		$ly=number_format($ly,0,".",",");
		$pagina->set_var("T_LY","$ly");
		
		$pdate2=$fechaInicio;
		$pActual=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorPactual=$db->fetch_array($pActual);
		$p_Actual=round($valorPactual['suma']);
		
		$sumaActualP=$sumaActualP+$p_Actual;
		$p_Actual=number_format($p_Actual,0,".",",");
		$pagina->set_var("P_ACTUAL","$p_Actual");
		
		$budgetP=$db->consulta("SELECT round(sum(`cantidad`)) sumP FROM `budget_daily` WHERE (`name` LIKE '$item_' or `name` LIKE '$item') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorBudgetP=$db->fetch_array($budgetP);
		$budgetPer=round($valorBudgetP['sumP']);
		
		$sumaBudgetP=$sumaBudgetP+$budgetPer;
		$budgetPer=number_format($budgetPer,0,".",",");
		$pagina->set_var("P_BUDGET","$budgetPer");
		
		$pdate2=$yearAnterior;
		$lyP=$db->consulta("SELECT round(sum(`room_sales`)) suma FROM `contract_room` WHERE `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) and `hnivel` = 2 ");
		$valorLyP=$db->fetch_array($lyP);
		$lyPer=round($valorLyP['suma']);
		
		$sumaLyP=$sumaLyP+$lyPer;
		$lyPer=number_format($lyPer,0,".",",");
		$pagina->set_var("P_LY","$lyPer");
		
		
		if ($color=="#F5F5F5"){$color = "#FCFCFC";}
		else{$color = "#F5F5F5";}
		if ($hotel == "stgo") $hotel = "bx";
		$hotel=strtoupper ($hotel);
	
		$pagina->set_var("BGCOLOR","$color");
		$pagina->set_var("HOTEL","$hotel");
		$pagina->parse("bITEM","ITEM",true);
	}
//******************************************************LINEA 4 SUMATORIA****************************************************************	
	$sumaActual2=number_format($sumaActual,0,".",",");
	$sumaBudget2=number_format($sumaBudget,0,".",",");
	$sumaLy2=number_format($sumaLy,0,".",",");
	$sumaActualP2=number_format($sumaActualP,0,".",",");
	$sumaBudgetP2=number_format($sumaBudgetP,0,".",",");
	$sumaLyP2=number_format($sumaLyP,0,".",",");
	$pagina->set_var("ITEM_NAME","Rooms Full Day");
	$pagina->set_var("ACTUAL","$sumaActual2");
	$pagina->set_var("T_BUDGET","$sumaBudget2");
	$pagina->set_var("T_LY","$sumaLy2");
	$pagina->set_var("P_ACTUAL","$sumaActualP2");
	$pagina->set_var("P_BUDGET","$sumaBudgetP2");
	$pagina->set_var("P_LY","$sumaLyP2");
    
	$color = "#F8FF78";
	
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);

//******************************************************LINEA Miscel_Revenue*************************************************************	
	
	$consulta = $db->consulta("SELECT * FROM `cb_rsm_revenue` where `hotel` like '$hotel' or `hotel` like 'TD' order by `id` asc");
	while($revenue = $db->fetch_array($consulta)){
		$idRevenue=$revenue['id'];
		if ($idRevenue<1380){
			$nameRevenue=$revenue['item_name'];
	
			$nameRevenue=str_replace(" ","_",$nameRevenue);
			$revenueQuery = $db->consulta("SELECT * FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and `hotel` LIKE '$hotel'");
			$valueRevenue = $db->fetch_array($revenueQuery);
			$valueRev=round($valueRevenue['value']);
			
			$sumaActual=$sumaActual+$valueRev;
			$valueRev=number_format($valueRev,0,".",",");
			$pagina->set_var("ACTUAL","$valueRev");
			
			$budgetQueryRev = $db->consulta("SELECT * FROM `budget_daily` WHERE `code` LIKE '$idRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and `hotel` LIKE '$hotel'");
			$valueRevenueBudget = $db->fetch_array($budgetQueryRev);
			$valueRev=0;
			$valueRev=$valueRev+round($valueRevenueBudget['cantidad']);
			$nameRev=$valueRevenueBudget['name'];
			
			$sumaBudget=$sumaBudget+$valueRev;
			$valueRev=number_format($valueRev,0,".",",");
			$pagina->set_var("T_BUDGET","$valueRev");
			
			$pyear2=$pyear-1;
			$budgetQueryRevLy = $db->consulta("SELECT * FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear2' and `hotel` LIKE '$hotel'");
			$valueRevenueBudgetLy = $db->fetch_array($budgetQueryRevLy);
			$valueRevLy=0;
			$valueRevLy=$valueRevLy+round($valueRevenueBudgetLy['value']);
			if ($nameRev=="")$nameRev=$valueRevenueBudgetLy['name'];
	
			$nameRev_=$nameRev;
			$nameRev=str_replace("_"," ",$nameRev);
			
			$sumaLy=$sumaLy+$valueRevLy;
			
			$valueRevLy=number_format($valueRevLy,0,".",",");
			$pagina->set_var("ITEM_NAME","$nameRev");
			$pagina->set_var("T_LY","$valueRevLy");
			
			$pdate2=$fechaInicio;
			$revActual=$db->consulta("SELECT round(sum(`value`)) sumRev FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$valorRevActual=$db->fetch_array($revActual);
			$rev_Actual=round($valorRevActual['sumRev']);
			
			$sumaActualP=$sumaActualP+$rev_Actual;
			$rev_Actual=number_format($rev_Actual,0,".",",");
			$pagina->set_var("P_ACTUAL","$rev_Actual");
			
			$budgetRevP=$db->consulta("SELECT round(sum(`cantidad`)) sumRevP FROM `budget_daily` WHERE (`name` LIKE '$nameRev' or `name` LIKE '$nameRev_') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$valorBudgetRevP=$db->fetch_array($budgetRevP);
			$budgetRevPer=round($valorBudgetRevP['sumRevP']);
			
			$sumaBudgetP=$sumaBudgetP+$budgetRevPer;
			$budgetRevPer=number_format($budgetRevPer,0,".",",");
			$pagina->set_var("P_BUDGET","$budgetRevPer");
			
			$pdate2=$yearAnterior;
			$lyRevP=$db->consulta("SELECT round(sum(`value`)) sumRevLy FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$valorRevLyP=$db->fetch_array($lyRevP);
			$lyRevPer=round($valorRevLyP['sumRevLy']);
			
			$sumaLyP=$sumaLyP+$lyRevPer;
			$lyRevPer=number_format($lyRevPer,0,".",",");
			$pagina->set_var("P_LY","$lyRevPer");
			
			if ($color=="#F5F5F5"){$color = "#FCFCFC";}
			else{$color = "#F5F5F5";}
			if ($hotel == "stgo") $hotel = "bx";
			$hotel=strtoupper ($hotel);
		
			$pagina->set_var("BGCOLOR","$color");
			$pagina->set_var("HOTEL","$hotel");
			$pagina->parse("bITEM","ITEM",true);
		}
	}

//******************************************************LINEA SUMATORIA****************************************************************	
	$sumaActual2=number_format($sumaActual,0,".",",");
	$sumaBudget2=number_format($sumaBudget,0,".",",");
	$sumaLy2=number_format($sumaLy,0,".",",");
	$sumaActualP2=number_format($sumaActualP,0,".",",");
	$sumaBudgetP2=number_format($sumaBudgetP,0,".",",");
	$sumaLyP2=number_format($sumaLyP,0,".",",");
	
	$pagina->set_var("ITEM_NAME","Gross Rooms Sales");
	$pagina->set_var("ACTUAL","$sumaActual2");
	$pagina->set_var("T_BUDGET","$sumaBudget2");
	$pagina->set_var("T_LY","$sumaLy2");
	$pagina->set_var("P_ACTUAL","$sumaActualP2");
	$pagina->set_var("P_BUDGET","$sumaBudgetP2");
	$pagina->set_var("P_LY","$sumaLyP2");

	$color = "#F8FF78";
	
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);


//******************************************************LINEA REBATES****************************************************************	

	
	$consulta = $db->consulta("SELECT * FROM `cb_rsm_revenue` where `hotel` like '$hotel' or `hotel` like 'TD' order by `id` asc");
	while($revenue = $db->fetch_array($consulta)){
		$idRevenue=$revenue['id'];
		if ($idRevenue>=1380){
			$nameRevenue=$revenue['item_name'];
	
			$nameRevenue=str_replace(" ","_",$nameRevenue);
			$revenueQuery = $db->consulta("SELECT * FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and `hotel` LIKE '$hotel'");
			$valueRevenue = $db->fetch_array($revenueQuery);
			$valueRev=round($valueRevenue['value']);
			
			$sumaActual=$sumaActual+$valueRev;
			$valueRev=number_format($valueRev,0,".",",");
			$pagina->set_var("ACTUAL","$valueRev");
			
			$budgetQueryRev = $db->consulta("SELECT * FROM `budget_daily` WHERE `code` LIKE '$idRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and `hotel` LIKE '$hotel'");
			$valueRevenueBudget = $db->fetch_array($budgetQueryRev);
			$valueRev=0;
			$valueRev=$valueRev+round($valueRevenueBudget['cantidad']);
			$nameRev=$valueRevenueBudget['name'];
			
			$sumaBudget=$sumaBudget+$valueRev;
			$valueRev=number_format($valueRev,0,".",",");
			$pagina->set_var("T_BUDGET","$valueRev");
			
			
			$budgetQueryRevLy = $db->consulta("SELECT * FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear2' and `hotel` LIKE '$hotel'");
			$valueRevenueBudgetLy = $db->fetch_array($budgetQueryRevLy);
			$valueRevLy=0;
			$valueRevLy=$valueRevLy+round($valueRevenueBudgetLy['value']);
			if ($nameRev=="")$nameRev=$valueRevenueBudgetLy['segment'];
	
			$nameRev_=$nameRev;
			$nameRev=str_replace("_"," ",$nameRev);
			
			$sumaLy=$sumaLy+$valueRevLy;
			$valueRevLy=number_format($valueRevLy,0,".",",");
			$pagina->set_var("ITEM_NAME","$nameRev");
			$pagina->set_var("T_LY","$valueRevLy");
			
			$pdate2=$fechaInicio;
			$revActual=$db->consulta("SELECT round(sum(`value`)) sumRev FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$valorRevActual=$db->fetch_array($revActual);
			$rev_Actual=round($valorRevActual['sumRev']);
			
			$sumaActualP=$sumaActualP+$rev_Actual;
			$rev_Actual=number_format($rev_Actual,0,".",",");
			$pagina->set_var("P_ACTUAL","$rev_Actual");
			
			$budgetRevP=$db->consulta("SELECT round(sum(`cantidad`)) sumRevP FROM `budget_daily` WHERE (`name` LIKE '$nameRev' or `name` LIKE '$nameRev_') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$valorBudgetRevP=$db->fetch_array($budgetRevP);
			$budgetRevPer=round($valorBudgetRevP['sumRevP']);
			
			$sumaBudgetP=$sumaBudgetP+$budgetRevPer;
			$budgetRevPer=number_format($budgetRevPer,0,".",",");
			$pagina->set_var("P_BUDGET","$budgetRevPer");
			
			$pdate2=$yearAnterior;
			$lyRevP=$db->consulta("SELECT round(sum(`value`)) sumRevLy FROM `micel_revenue` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$valorRevLyP=$db->fetch_array($lyRevP);
			$lyRevPer=round($valorRevLyP['sumRevLy']);
			
			$sumaLyP=$sumaLyP+$lyRevPer;
			$lyRevPer=number_format($lyRevPer,0,".",",");
			$pagina->set_var("P_LY","$lyRevPer");
			
			if ($color=="#F5F5F5"){$color = "#FCFCFC";}
			else{$color = "#F5F5F5";}
			if ($hotel == "stgo") $hotel = "bx";
			$hotel=strtoupper ($hotel);
		
			$pagina->set_var("BGCOLOR","$color");
			$pagina->set_var("HOTEL","$hotel");
			$pagina->parse("bITEM","ITEM",true);
		}
	}
//******************************************************LINEA SUMATORIA****************************************************************	
	$sumaActual2=number_format($sumaActual,0,".",",");
	$sumaBudget2=number_format($sumaBudget,0,".",",");
	$sumaLy2=number_format($sumaLy,0,".",",");
	$sumaActualP2=number_format($sumaActualP,0,".",",");
	$sumaBudgetP2=number_format($sumaBudgetP,0,".",",");
	$sumaLyP2=number_format($sumaLyP,0,".",",");
	
	
	$pagina->set_var("ITEM_NAME","Net Rooms Sales");
	$pagina->set_var("ACTUAL","$sumaActual2");
	$pagina->set_var("T_BUDGET","$sumaBudget2");
	$pagina->set_var("T_LY","$sumaLy2");
	$pagina->set_var("P_ACTUAL","$sumaActualP2");
	$pagina->set_var("P_BUDGET","$sumaBudgetP2");
	$pagina->set_var("P_LY","$sumaLyP2");

	$sumaActualT=$sumaActualT+$sumaActual;
	$sumaBudgetT=$sumaBudgetT+$sumaBudget;
	$sumaLyT=$sumaLyT+$sumaLy;
	$sumaActualPT=$sumaActualPT+$sumaActualP;
	$sumaBudgetPT=$sumaBudgetPT+$sumaBudgetP;
	$sumaLyPT=$sumaLyPT+$sumaLyP;

	$color = "#F8FF78";
	
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);

//******************************************************LINEA MISCELANEOS****************************************************************	

	$sumaActualM=0;$sumaBudgetM=0;$sumaLyM=0;$sumaActualPM=0;$sumaBudgetPM=0;$sumaLyPM=0;
	$consulta = $db->consulta("SELECT * FROM `cb_miscellaneous` where `hotel` like '$hotel' or `hotel` like 'TD' order by `id` asc");
	while($revenue = $db->fetch_array($consulta)){
		$idRevenue=$revenue['id'];
		
		$nameRevenue=$revenue['item_name'];

		$nameRevenue=str_replace(" ","_",$nameRevenue);
		$revenueQuery = $db->consulta("SELECT * FROM `miscellaneous_sales` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and `hotel` LIKE '$hotel'");
		$valueRevenue = $db->fetch_array($revenueQuery);
		$valueRev=round($valueRevenue['value']);
		
		$sumaActualM=$sumaActualM+$valueRev;
		$valueRev=number_format($valueRev,0,".",",");
		$pagina->set_var("ACTUAL","$valueRev");
		
		$budgetQueryRev = $db->consulta("SELECT * FROM `budget_daily` WHERE `code` LIKE '$idRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and `hotel` LIKE '$hotel'");
		$valueRevenueBudget = $db->fetch_array($budgetQueryRev);
		$valueRev=0;
		$valueRev=$valueRev+round($valueRevenueBudget['cantidad']);
		$nameRev=$valueRevenueBudget['name'];
		
		$sumaBudgetM=$sumaBudgetM+$valueRev;
		$valueRev=number_format($valueRev,0,".",",");
		$pagina->set_var("T_BUDGET","$valueRev");
		
		
		$budgetQueryRevLy = $db->consulta("SELECT * FROM `miscellaneous_sales` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear2' and `hotel` LIKE '$hotel'");
		$valueRevenueBudgetLy = $db->fetch_array($budgetQueryRevLy);
		$valueRevLy=0;
		$valueRevLy=$valueRevLy+round($valueRevenueBudgetLy['value']);
		if ($nameRev=="")$nameRev=$valueRevenueBudgetLy['segment'];

		$nameRev_=$nameRev;
		$nameRev=str_replace("_"," ",$nameRev);
		
		$sumaLyM=$sumaLyM+$valueRevLy;
		$valueRevLy=number_format($valueRevLy,0,".",",");
		$pagina->set_var("ITEM_NAME","$nameRev");
		$pagina->set_var("T_LY","$valueRevLy");
		
		$pdate2=$fechaInicio;
		$revActual=$db->consulta("SELECT round(sum(`value`)) sumRev FROM `miscellaneous_sales` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorRevActual=$db->fetch_array($revActual);
		$rev_Actual=round($valorRevActual['sumRev']);
		
		$sumaActualPM=$sumaActualPM+$rev_Actual;
		$rev_Actual=number_format($rev_Actual,0,".",",");
		$pagina->set_var("P_ACTUAL","$rev_Actual");
		
		$budgetRevP=$db->consulta("SELECT round(sum(`cantidad`)) sumRevP FROM `budget_daily` WHERE (`name` LIKE '$nameRev' or `name` LIKE '$nameRev_') AND `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorBudgetRevP=$db->fetch_array($budgetRevP);
		$budgetRevPer=round($valorBudgetRevP['sumRevP']);
		
		$sumaBudgetPM=$sumaBudgetPM+$budgetRevPer;
		$budgetRevPer=number_format($budgetRevPer,0,".",",");
		$pagina->set_var("P_BUDGET","$budgetRevPer");
		
		$pdate2=$yearAnterior;
		$lyRevP=$db->consulta("SELECT round(sum(`value`)) sumRevLy FROM `miscellaneous_sales` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorRevLyP=$db->fetch_array($lyRevP);
		$lyRevPer=round($valorRevLyP['sumRevLy']);
		
		$sumaLyPM=$sumaLyPM+$lyRevPer;
		$lyRevPer=number_format($lyRevPer,0,".",",");
		$pagina->set_var("P_LY","$lyRevPer");
		
		if ($color=="#F5F5F5"){$color = "#FCFCFC";}
		else{$color = "#F5F5F5";}
		if ($hotel == "stgo") $hotel = "bx";
		$hotel=strtoupper ($hotel);
	
		$pagina->set_var("BGCOLOR","$color");
		$pagina->set_var("HOTEL","$hotel");
		$pagina->parse("bITEM","ITEM",true);
	}

//******************************************************LINEA SUMATORIA****************************************************************	
	$sumaActualM2=number_format($sumaActualM,0,".",",");
	$sumaBudgetM2=number_format($sumaBudgetM,0,".",",");
	$sumaLyM2=number_format($sumaLyM,0,".",",");
	$sumaActualPM2=number_format($sumaActualPM,0,".",",");
	$sumaBudgetPM2=number_format($sumaBudgetPM,0,".",",");
	$sumaLyPM2=number_format($sumaLyPM,0,".",",");
	
	
	$pagina->set_var("ITEM_NAME","Sub-Total Others Sales");
	$pagina->set_var("ACTUAL","$sumaActualM2");
	$pagina->set_var("T_BUDGET","$sumaBudgetM2");
	$pagina->set_var("T_LY","$sumaLyM2");
	$pagina->set_var("P_ACTUAL","$sumaActualPM2");
	$pagina->set_var("P_BUDGET","$sumaBudgetPM2");
	$pagina->set_var("P_LY","$sumaLyPM2");

	$sumaActualT=$sumaActualT+$sumaActualM;
	$sumaBudgetT=$sumaBudgetT+$sumaBudgetM;
	$sumaLyT=$sumaLyT+$sumaLyM;
	$sumaActualPT=$sumaActualPT+$sumaActualPM;
	$sumaBudgetPT=$sumaBudgetPT+$sumaBudgetPM;
	$sumaLyPT=$sumaLyPT+$sumaLyPM;

	$color = "#F8FF78";
	
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);


//*************************************************LINEA RESTAURANT SALES*******************************************************	
    
	$valueRevLy=0;$valueRev=0;$sumaActualR=0;$sumaBudgetR=0;$sumaLyR=0;$sumaActualPR=0;$sumaBudgetPR=0;$sumaLyPR=0;
	$consulta = $db->consulta("SELECT * FROM `cb_food_bav_area` WHERE `grupo` LIKE 'restaurant' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) order by `id` asc");
	//echo($sumaActualR);echo('<br>');
	while($revenue = $db->fetch_array($consulta)){
		
		$idRevenue=$revenue['id'];
		$nameRevenue=$revenue['item_name'];

		$nameRevenue=str_replace(" ","_",$nameRevenue);
		$revenueQuery = $db->consulta("SELECT * FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valueRevenue = $db->fetch_array($revenueQuery);
		$valueRev=round($valueRevenue['food']+$valueRevenue['beverage']);
		$sumaActualR=$sumaActualR+$valueRev;
		
		$budgetQueryRev = $db->consulta("SELECT * FROM `cb_budget` WHERE `code` ='$idRevenue' AND `categoria` IN ( '1', '3')");
		while($budgetCat = $db->fetch_array($budgetQueryRev)){
			$nameCat=($budgetCat['name']);
			$nameCat=str_replace(" ","_",$nameCat);
			$budgetRest = $db->consulta("SELECT * FROM `budget_daily` WHERE `code` ='$idRevenue' AND `name` LIKE '$nameCat' and`pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$budgetResult = $db->fetch_array($budgetRest);
			$valueRev=round($budgetResult['cantidad']);
			$sumaBudgetR=$sumaBudgetR+$valueRev;
		}
			
		$pyear2=$pyear-1;
			
		$budgetQueryRevLy = $db->consulta("SELECT * FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valueRevenue = $db->fetch_array($budgetQueryRevLy);
		$valueRev=round($valueRevenue['food']+$valueRevenue['beverage']);
		$sumaLyR=$sumaLyR+$valueRev;
		
		
		
		$pdate2=$fechaInicio;
		$revActual=$db->consulta("SELECT round(sum(`food`)) sumFood, round(sum(`beverage`)) sumBev FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorRevActual=$db->fetch_array($revActual);
		$rev_Actual=round($valorRevActual['sumFood']+$valorRevActual['sumBev']);
		$sumaActualPR=$sumaActualPR+$rev_Actual;
		
		
		$budgetQueryRevP = $db->consulta("SELECT * FROM `cb_budget` WHERE `code` ='$idRevenue' AND `categoria` IN ( '1', '3')");
		while($budgetCatP = $db->fetch_array($budgetQueryRevP)){
			$nameCat=($budgetCatP['name']);
			$nameCat=str_replace(" ","_",$nameCat);
			$budgetRest = $db->consulta("SELECT sum(cantidad) sumaR FROM `budget_daily` WHERE `code` ='$idRevenue' AND `name` LIKE '$nameCat' and`pciclo` = '$period' AND `pday` <= '$pday' and `pday` >= '01' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$budgetResult = $db->fetch_array($budgetRest);
			$valueRev=round($budgetResult['sumaR']);
			$sumaBudgetPR=$sumaBudgetPR+$valueRev;
		}
		
		$pyear2=$pyear-1;
		$budgetQueryRevLy=$db->consulta("SELECT round(sum(`food`)) sumFood, round(sum(`beverage`)) sumBev FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' and `pday` >= '01' and `pday` <= '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$budgetResult=$db->fetch_array($budgetQueryRevLy);
		$lyRevPer=round($budgetResult['sumFood']+$budgetResult['sumBev']);
		$sumaLyPR=$sumaLyPR+$lyRevPer;
		
		
	}
	
	$sumaActualR2=number_format($sumaActualR,0,".",",");
	$sumaBudgetR2=number_format($sumaBudgetR,0,".",",");
	$sumaLyR2=number_format($sumaLyR,0,".",",");
	$sumaActualPR2=number_format($sumaActualPR,0,".",",");
	$sumaBudgetPR2=number_format($sumaBudgetPR,0,".",",");
	$sumaLyPR2=number_format($sumaLyPR,0,".",",");
	
	$pagina->set_var("ITEM_NAME","Restaurant Sales");
	$pagina->set_var("ACTUAL","$sumaActualR2");
	$pagina->set_var("T_BUDGET","$sumaBudgetR2");
	$pagina->set_var("T_LY","$sumaLyR2");
	$pagina->set_var("P_ACTUAL","$sumaActualPR2");
	$pagina->set_var("P_BUDGET","$sumaBudgetPR2");
	$pagina->set_var("P_LY","$sumaLyPR2");
	
	if ($color=="#F5F5F5"){$color = "#FCFCFC";}
	else{$color = "#F5F5F5";}
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);
	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);


//**************************************************LINEA LOUNGE SALES********************************************************	
    
	$sumaActualL=0;$sumaBudgetL=0;$sumaLyL=0;$sumaActualPL=0;$sumaBudgetPL=0;$sumaLyPL=0;
	$consulta = $db->consulta("SELECT * FROM `cb_food_bav_area` WHERE `grupo` LIKE 'Lounge' and ((`hotel` = '$hotel') or (`hotel` like 'TD')) order by `id` asc");
	while($revenue = $db->fetch_array($consulta)){
		$idRevenue=$revenue['id'];
		$nameRevenue=$revenue['item_name'];

		$nameRevenue=str_replace(" ","_",$nameRevenue);
		$revenueQuery = $db->consulta("SELECT * FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valueRevenue = $db->fetch_array($revenueQuery);
		$valueRev=round($valueRevenue['food']+$valueRevenue['beverage']);
		
		$sumaActualL=$sumaActualL+$valueRev;
		
		
		$budgetQueryRev = $db->consulta("SELECT * FROM `cb_budget` WHERE `code` ='$idRevenue' AND `categoria` IN ( '1', '3')");
		while($budgetCat = $db->fetch_array($budgetQueryRev)){
			$nameCat=($budgetCat['name']);
			$nameCat=str_replace(" ","_",$nameCat);
			$budgetRest = $db->consulta("SELECT * FROM `budget_daily` WHERE `code` ='$idRevenue' AND `name` LIKE '$nameCat' and`pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$budgetResult = $db->fetch_array($budgetRest);
			$valueRev=round($budgetResult['cantidad']);
			$sumaBudgetL=$sumaBudgetL+$valueRev;
		}
		
		$pyear2=$pyear-1;
		$budgetQueryRevLy = $db->consulta("SELECT * FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear2' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$values = $db->fetch_array($budgetQueryRevLy);
		$valueRev=round($values['food']+$values['beverage']);
		$sumaLyL=$sumaLyL+$valueRev;
		
				
		$pdate2=$fechaInicio;
		$revActual=$db->consulta("SELECT round(sum(`food`)) sumFood, round(sum(`beverage`)) sumBev FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear' and ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorRevActual=$db->fetch_array($revActual);
		$rev_Actual=round($valorRevActual['sumFood']+$valorRevActual['sumBev']);
		$sumaActualPL=$sumaActualPL+$rev_Actual;
		
		
		
		$budgetRevP = $db->consulta("SELECT * FROM `cb_budget` WHERE `code` ='$idRevenue' AND `categoria` IN ( '1', '3')");
		while($valorBudgetRevP = $db->fetch_array($budgetRevP)){
			$nameCat=($valorBudgetRevP['name']);
			$nameCat=str_replace(" ","_",$nameCat);
			$budgetRest = $db->consulta("SELECT sum(cantidad) sumaR FROM `budget_daily` WHERE `code` ='$idRevenue' AND `name` LIKE '$nameCat' and `pciclo` = '$period' AND `pday` <= '$pday' and `pday` >= '01' and `pyear` = '$pyear' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
			$budgetResult = $db->fetch_array($budgetRest);
			$valueRev=round($budgetResult['sumaR']);
			$sumaBudgetPL=$sumaBudgetPL+$valueRev;
		}
		
		$pyear2=$pyear-1;
		
		$lyRevP=$db->consulta("SELECT round(sum(`food`)) sumFood, round(sum(`beverage`)) sumBev FROM `food_beverage` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND  `pday` >= '01' and `pday` <= '$pday'  and `pyear` = '$pyear2' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$budgetResult=$db->fetch_array($lyRevP);
		$lyRevPer=round($budgetResult['sumFood']+$budgetResult['sumBev']);
		$sumaLyPL=$sumaLyPL+$lyRevPer;
		
	}
	$sumaActualL2=number_format($sumaActualL,0,".",",");
	$sumaBudgetL2=number_format($sumaBudgetL,0,".",",");
	$sumaLyL2=number_format($sumaLyL,0,".",",");
	$sumaActualPL2=number_format($sumaActualPL,0,".",",");
	$sumaBudgetPL2=number_format($sumaBudgetPL,0,".",",");
	$sumaLyPL2=number_format($sumaLyPL,0,".",",");
	
	$pagina->set_var("ITEM_NAME","Lounge Sales");
	$pagina->set_var("ACTUAL","$sumaActualL2");
	$pagina->set_var("T_BUDGET","$sumaBudgetL2");
	$pagina->set_var("T_LY","$sumaLyL2");
	$pagina->set_var("P_ACTUAL","$sumaActualPL2");
	$pagina->set_var("P_BUDGET","$sumaBudgetPL2");
	$pagina->set_var("P_LY","$sumaLyPL2");
	
	if ($color=="#F5F5F5"){$color = "#FCFCFC";}
	else{$color = "#F5F5F5";}
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);
	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);


//******************************************************LINEA BANQUET SALES***************************************************************	
    
	$sumaActualB=0;$sumaBudgetB=0;$sumaLyB=0;$sumaActualPB=0;$sumaBudgetPB=0;$sumaLyPB=0;
	$consulta = $db->consulta("SELECT * FROM `cb_type_banquet` WHERE `categoria` =1 or `categoria` =3");
	while($revenue = $db->fetch_array($consulta)){
		$idRevenue=$revenue['id'];
		$nameRevenue=$revenue['item_name'];

		$nameRevenue=str_replace(" ","_",$nameRevenue);
		$revenueQuery = $db->consulta("SELECT * FROM `banquet_sales` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valueRevenue = $db->fetch_array($revenueQuery);
		$valueRev=round($valueRevenue['banquet_value']);
		
		$sumaActualB=$sumaActualB+$valueRev;
		
		$budgetQueryRev = $db->consulta("SELECT * FROM `budget_daily` WHERE `code` LIKE '$idRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valueRevenueBudget = $db->fetch_array($budgetQueryRev);
		$valueRev=0;
		$valueRev=$valueRev+round($valueRevenueBudget['cantidad']);
		$nameRev=$valueRevenueBudget['name'];
		
		$sumaBudgetB=$sumaBudgetB+$valueRev;
		
		$budgetQueryRevLy = $db->consulta("SELECT * FROM `banquet_sales` WHERE `segment` LIKE '$nameRevenue' AND `pciclo` = '$period' AND `pday` = '$pday' and `pyear` = '$pyear2' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valueRevenueBudgetLy = $db->fetch_array($budgetQueryRevLy);
		$valueRevLy=0;
		$valueRevLy=$valueRevLy+round($valueRevenueBudgetLy['banquet_value']);
		if ($nameRev=="")$nameRev=$valueRevenueBudgetLy['segment'];

		$nameRev_=$nameRev;
		$nameRev=str_replace("_"," ",$nameRev);
		
		$sumaLyB=$sumaLyB+$valueRevLy;
		
		$pdate2=$fechaInicio;
		$revActual=$db->consulta("SELECT round(sum(`banquet_value`)) sumBan FROM `banquet_sales` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' AND `pday` <= '$pday' and `pday` >= '01' and `pyear` = '$pyear' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorRevActual=$db->fetch_array($revActual);
		$rev_Actual=round($valorRevActual['sumBan']);
		
		$sumaActualPB=$sumaActualPB+$rev_Actual;
		
		$budgetRevP=$db->consulta("SELECT round(sum(`cantidad`)) sumRevP FROM `budget_daily` WHERE (`name` LIKE '$nameRev' or `name` LIKE '$nameRev_') AND `pciclo` = '$period' AND `pday` <= '$pday' and `pday` >= '01' and `pyear` = '$pyear' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorBudgetRevP=$db->fetch_array($budgetRevP);
		$budgetRevPer=round($valorBudgetRevP['sumRevP']);
		
		$sumaBudgetPB=$sumaBudgetPB+$budgetRevPer;
		
		$pdate2=$yearAnterior;
		$lyRevP=$db->consulta("SELECT round(sum(`banquet_value`)) sumRevLy FROM `banquet_sales` WHERE `segment` LIKE '$nameRevenue' and `pciclo` = '$period' AND `pday` <= '$pday' and `pday` >= '01' and `pyear` = '$pyear2' and  ((`hotel` = '$hotel') or (`hotel` like 'TD'))");
		$valorRevLyP=$db->fetch_array($lyRevP);
		$lyRevPer=round($valorRevLyP['sumRevLy']);
		
		$sumaLyPB=$sumaLyPB+$lyRevPer;
	}
	$sumaActualB2=number_format($sumaActualB,0,".",",");
	$sumaBudgetB2=number_format($sumaBudgetB,0,".",",");
	$sumaLyB2=number_format($sumaLyB,0,".",",");
	$sumaActualPB2=number_format($sumaActualPB,0,".",",");
	$sumaBudgetPB2=number_format($sumaBudgetPB,0,".",",");
	$sumaLyPB2=number_format($sumaLyPB,0,".",",");
	
	
	$pagina->set_var("ITEM_NAME","Banquet Sales");
	$pagina->set_var("ACTUAL","$sumaActualB2");
	$pagina->set_var("T_BUDGET","$sumaBudgetB2");
	$pagina->set_var("T_LY","$sumaLyB2");
	$pagina->set_var("P_ACTUAL","$sumaActualPB2");
	$pagina->set_var("P_BUDGET","$sumaBudgetPB2");
	$pagina->set_var("P_LY","$sumaLyPB2");
	
	if ($color=="#F5F5F5"){$color = "#FCFCFC";}
	else{$color = "#F5F5F5";}
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);
	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);

//******************************************************LINEA SUMATORIA****************************************************************	
	$sumaActualR=$sumaActualR+$sumaActualL+$sumaActualB;
	$sumaBudgetR=$sumaBudgetR+$sumaBudgetL+$sumaBudgetB;
	$sumaLyR=$sumaLyR+$sumaLyL+$sumaLyB;
	$sumaActualPR=$sumaActualPR+$sumaActualPL+$sumaActualPB;
	$sumaBudgetPR=$sumaBudgetPR+$sumaBudgetPL+$sumaBudgetPB;
	$sumaLyPR=$sumaLyPR+$sumaLyPL+$sumaLyPB;
	
	$sumaActualR2=number_format($sumaActualR,0,".",",");
	$sumaBudgetR2=number_format($sumaBudgetR,0,".",",");
	$sumaLyR2=number_format($sumaLyR,0,".",",");
	$sumaActualPR2=number_format($sumaActualPR,0,".",",");
	$sumaBudgetPR2=number_format($sumaBudgetPR,0,".",",");
	$sumaLyPR2=number_format($sumaLyPR,0,".",",");
	
	$pagina->set_var("ITEM_NAME","Total F&B Sales");
	$pagina->set_var("ACTUAL","$sumaActualR2");
	$pagina->set_var("T_BUDGET","$sumaBudgetR2");
	$pagina->set_var("T_LY","$sumaLyR2");
	$pagina->set_var("P_ACTUAL","$sumaActualPR2");
	$pagina->set_var("P_BUDGET","$sumaBudgetPR2");
	$pagina->set_var("P_LY","$sumaLyPR2");
	
	$sumaActualT=$sumaActualT+$sumaActualR;
	$sumaBudgetT=$sumaBudgetT+$sumaBudgetR;
	$sumaLyT=$sumaLyT+$sumaLyR;
	$sumaActualPT=$sumaActualPT+$sumaActualPR;
	$sumaBudgetPT=$sumaBudgetPT+$sumaBudgetPR;
	$sumaLyPT=$sumaLyPT+$sumaLyPR;

	$color = "#F8FF78";
	
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);
//******************************************************LINEA SUMATORIA TOTAL*************************************************************	
	$sumaActualT2=number_format($sumaActualT,0,".",",");
	$sumaBudgetT2=number_format($sumaBudgetT,0,".",",");
	$sumaLyT2=number_format($sumaLyT,0,".",",");
	$sumaActualPT2=number_format($sumaActualPT,0,".",",");
	$sumaBudgetPT2=number_format($sumaBudgetPT,0,".",",");
	$sumaLyPT2=number_format($sumaLyPT,0,".",",");
	
	
	$pagina->set_var("ITEM_NAME","Total Hotel Sales");
	$pagina->set_var("ACTUAL","$sumaActualT2");
	$pagina->set_var("T_BUDGET","$sumaBudgetT2");
	$pagina->set_var("T_LY","$sumaLyT2");
	$pagina->set_var("P_ACTUAL","$sumaActualPT2");
	$pagina->set_var("P_BUDGET","$sumaBudgetPT2");
	$pagina->set_var("P_LY","$sumaLyPT2");
	

	$color = "#C3FFC3";
	
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);

	$pagina->set_var("BGCOLOR","$color");
	$pagina->set_var("HOTEL","$hotel");
	$pagina->parse("bITEM","ITEM",true);

//******************************************************LINEA UNDER TOTAL*************************************************************	
	
	$budget=$sumaActualT-$sumaBudgetT;
	$ly=$sumaActualT-$sumaLyT;
	
	$budgetT=$sumaActualPT-$sumaBudgetPT;
	$lyT=$sumaActualPT-$sumaLyPT;
	
	$budget=number_format($budget,0,".",",");
	$ly=number_format($ly,0,".",",");
	$budgetT=number_format($budgetT,0,".",",");
	$lyT=number_format($lyT,0,".",",");
	
	$pagina->set_var("ITEM_NAME","Over/Under");
	$pagina->set_var("ACTUAL"," ");
	$pagina->set_var("T_BUDGET","$budget");
	$pagina->set_var("T_LY","$ly");
	$pagina->set_var("P_ACTUAL","");
	$pagina->set_var("P_BUDGET","$budgetT");
	$pagina->set_var("P_LY","$lyT");
	

	$color = "#F8FF78";
	
	if ($hotel == "stgo") $hotel = "bx";
	$hotel=strtoupper ($hotel);
	$prev=$pday-1;
	$next=$pday+1;
	$pagina->set_var("PREVIO","$prev");
	$pagina->set_var("SIGUIENTE","$next");
	
	$pagina->set_var("BGCOLOR","$color");
	
	$hotelName=strtoupper($_SESSION['nomHotel']);
	
	$pagina->set_var("HOTEL","$hotelName");
	$pagina->parse("bITEM","ITEM",true);

	
	$pagina->parse("CENTRO",array("report1"));
	$pagina->parse("SALIDA",array("sistema"));
}
$pagina->p("SALIDA");

?>